import { Controller, Get, Res, UseInterceptors } from '@nestjs/common';
import { UserService } from '../services/UserService';
import { UserCreateDto } from '../dto/UserCreateDto';
import { Post } from '@nestjs/common';
import { Body } from '@nestjs/common';
import { ResponseInterceptor, ResponseResult } from '../interceptor/response';
import { create } from 'domain';

@Controller('user')
export class UserController {
  constructor(private UserService: UserService) {}
  @Post('add')
  async create(@Body() data: UserCreateDto) {
    const result = await this.UserService.create(data);
    return ResponseResult.Success(result);
  }

  @Post('create')
  async searchByName(@Body() data: UserCreateDto) {
    const result = await this.UserService.findByName(data.username);
    return ResponseResult.Success(result);
  }
  @Get()
  async list() {
    const result = await this.UserService.list();
    return ResponseResult.Success(result);
  }
}
